package com.qg.controller;


import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.fastjson.JSON;
import com.qg.pojo.QgUser;
import com.qg.service.LocalQgUserService;
import com.qg.utils.EmptyUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;



/**
 * 用户控制类
 */
@Controller
@RequestMapping("/api")
public class UserController {

   @Reference
    private LocalQgUserService localQgUserService;

    /**
     * 用户登陆功能
     * @param phone
     * @param password
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "loginUser" ,method = RequestMethod.POST)
    @ResponseBody
    public String loginUser(String phone,String password)throws Exception{
        //用户对象接收查询出来的值
       QgUser qgUser= localQgUserService.logUser(phone,password);
       //判断用户是否为空
       if(EmptyUtils.isEmpty(qgUser)){
           //当用户为空时，返回提示信息
           return "sb";
       }
        String user=JSON.toJSONString(qgUser);
        return user;
    }

    /**
     * 注销用户
     * @param ID
     * @return
     * @throws Exception
     */
    public String a(String ID) throws Exception{
        return "";
    }

}
